<template>
    <div class="home">
        21
        <div @click="button()">anniu</div>
        <img :src="logo" />
    </div>
</template>

<script>
import { mapMutations, mapGetters } from 'vuex';

export default {
    name: 'homePage',
    data() {
        return {
            logo: require('images/logo.png')
        };
    },
    computed: {
        ...mapGetters('test', ['root'])
    },
    created() {
        // console.log(1);
    },
    mounted() {
        console.log(this.$vm);
        this.$toast.fail('名字不正确');
        this.setKeepAlive(['homePage']);
        let t = this.gen();
        t.next(1);
        t.next(2);
        t.next(3);
        t.next(4);

        var arr = [1, 2, 3];

        function getSum(a, b) {
            return a + b;
        }
        function mix() {
            return arr.reduce(getSum);
        }
        let list = mix();
        console.log(list);
    },
    methods: {
        *gen() {
            let a = yield 111;
            console.log(a);
            let b = yield 222;
            console.log(b);
            let c = yield 333;
            console.log(c);
            let d = yield 444;
            console.log(d);
        },
        ...mapMutations('keepAlive', ['setKeepAlive']),
        button() {
            const { fullPath } = this.$route;
            this.$router.replace({
                path: '/redirect' + fullPath
            });
        }
    }
};
</script>
